pub fn split_into_args(input: &str) -> Vec<String> {
    let mut args = vec![];
    let mut current_arg = String::new();
    let mut in_quotes = false;

    for c in input.chars() {
        match c {
            ' ' if !in_quotes => {
                if !current_arg.is_empty() {
                    args.push(current_arg.clone());
                    current_arg.clear();
                }
            }
            '"' => {
                 if in_quotes==true&&current_arg.is_empty(){
                    args.push("".to_string());
                 }

                 in_quotes = !in_quotes;
            }
            _ => {
                current_arg.push(c);
            }
        }
    }

    if !current_arg.is_empty() {
        args.push(current_arg);
    }

    args
}

#[cfg(test)]
mod tests {
    use crate::parse::split_into_args;
    #[test]
    fn main() {
        let input_string = r#"test "arg 1" "arg 2" arg3"#;
        let args = split_into_args(input_string);
        assert_eq!(args,vec!["test","arg 1","arg 2","arg3"]);

        let input_string = "--test 2 --test2  3 ";
        let args = split_into_args(input_string);
        assert_eq!(args,vec!["--test","2","--test2","3"]);   

        let input_string = "--table \"\"";
        let args = split_into_args(input_string);
        assert_eq!(args,vec!["--table",""]);      
    }
}
